package com.fcscs.cservice.client.main.configuration.activitylog;

import java.util.ArrayList;
import java.util.List;

import com.extjs.gxt.ui.client.Style.HorizontalAlignment;
import com.extjs.gxt.ui.client.store.ListStore;
import com.extjs.gxt.ui.client.widget.HorizontalPanel;
import com.extjs.gxt.ui.client.widget.grid.ColumnConfig;
import com.extjs.gxt.ui.client.widget.grid.ColumnData;
import com.extjs.gxt.ui.client.widget.grid.Grid;
import com.extjs.gxt.ui.client.widget.grid.GridCellRenderer;
import com.fcscs.core.common.MainPaginationSearchModel;
import com.fcscs.core.gwt.common.CoreUtil;
import com.fcscs.core.gwt.common.SearchExecutor;
import com.fcscs.core.gwt.common.ui.PagingSearchResultsPanel;
import com.fcscs.cservice.client.common.CServiceConstants;
import com.fcscs.cservice.client.common.model.reservation.ReservationViewModelData;
import com.fcscs.share.gwt.common.ShareGWTConstants;

public class ActivityLogsGrid extends
		PagingSearchResultsPanel<ReservationViewModelData, MainPaginationSearchModel> {

	public ActivityLogsGrid(String title,
			SearchExecutor<ReservationViewModelData, MainPaginationSearchModel> exe) {
		super(title, exe, (Object[]) null);
		setCollapsible(false);
		setSize(740, 350);
	}

	@Override
	protected List<ColumnConfig> getColumnConfig(Object... params) {
		List<ColumnConfig> columns = new ArrayList<ColumnConfig>();
		ColumnConfig cc = CoreUtil.createNonSortableColumnConf(ShareGWTConstants.ROOM,
				ShareGWTConstants.SHARE_GWT_CONSTANTS.room(), 120);
		columns.add(cc);

		columns.add(CoreUtil.createNonSortableColumnConf(ShareGWTConstants.GUEST_NAME,
				ShareGWTConstants.SHARE_GWT_CONSTANTS.guestName(), 120));

		columns.add(CoreUtil.createNonSortableColumnConf(ShareGWTConstants.ARRIVAL_DATE,
				ShareGWTConstants.SHARE_GWT_CONSTANTS.arrivalDate(), 120));
		columns.add(CoreUtil.createNonSortableColumnConf(ShareGWTConstants.DEPARTUAL_DATE,
				ShareGWTConstants.SHARE_GWT_CONSTANTS.departureDate(), 120));

		columns.add(CoreUtil.createNonSortableColumnConf(CServiceConstants.RESERVATION_STATUS,
				CServiceConstants.CSERVICE_CONSTANTS.reservationStatus(), 120));

		cc = CoreUtil.createNonSortableColumnConf(CServiceConstants.FOLIO,
				CServiceConstants.CSERVICE_CONSTANTS.folio(), 120);
		cc.setRenderer(new GridCellRenderer<ReservationViewModelData>() {
			public Object render(final ReservationViewModelData model, String property, ColumnData config,
					int rowIndex, int colIndex, ListStore<ReservationViewModelData> store,
					final Grid<ReservationViewModelData> grid) {
				HorizontalPanel hr = new HorizontalPanel();
				hr.setId("FolioGrid_show_folio_hr");
				hr.setHorizontalAlign(HorizontalAlignment.LEFT);

				// HighLightIconButton ib = createShowFolioDialog(model);
				// ib.setStyleAttribute("marginLeft", "3px");
				// ib.setId("FolioGrid_show_folio_button");
				// hr.add(ib);
				return hr;
			}
		});
		columns.add(cc);

		return columns;
	}

}
